using System;
using System.Collections.Generic;
using System.Linq;

using Atomic.Structures;

namespace Atomic.Thermodynamics
{
	[Serializable]
	public class ReferenceStateLinearFitting : RedlichKisterPolynomial
	{
		public ReferenceStateLinearFitting(Atom[] atoms, double[] referenceEnergies)
			: base(-1, atoms, new double[0], referenceEnergies)
		{
		}

		/// <summary>
		/// Extracts pure states from the listed energies and uses them for the reference system. 
		/// </summary>
		public static ReferenceStateLinearFitting FitReferenceStates(IEnumerable<CompositionMapping> energies)
		{
			RedlichKisterPolynomial rk = FitGroundState(-1, energies, ExtractReferenceEnergies(energies));
			return new ReferenceStateLinearFitting(rk.Atoms.ToArray(), rk.ReferenceEnergies.ToArray());
		}
	}
}
